<?php

/**
 * Формы копира страниц
 */
class PickerForm extends Zend_Form {

    /**
     * Форма выбора копируемой страницы
     *
     * @param array $options 'pid' => #ID текущей страницы, 'sid' => #ID секции
     * @return PickerForm
     */
    public function Picker($options = null) {
        $this->setName('picker');
        $t = Zend_Registry::get('Zend_Locale');
        $model = new PageModel();
        $parent = new Zend_Form_Element_Select('pid');
        $array = $model->getPagesList();
        unset($array[$options['pid']]);
        $empty = array(0 => $t->_('Undefined'));
        $parent->addMultiOptions($empty + $array)
                ->setLabel('Pick page')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->setRequired();

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Save');
        $submit->setAttrib('id', 'submitbutton');

        $this->addElements(array($parent, $submit));
        $this->setAction(ADMIN_URL . '/pages/modify/id/' . $options['sid']);
        $t = Zend_Registry::get('Zend_Locale');
        $this->setDefaultTranslator($t);
        return $this;
    }

}